package model

import business.AutoMoveable
import enums.Direction
import org.itheima.kotlin.game.core.Painter

/** gameover字样
 *
 * 自动移动的能力
 * */
class GameOverText:IView ,AutoMoveable{
    override val currentDirection: Direction=Direction.UP
    override val speed: Int=10
    override var badDirection: Direction?=null
    override var x: Int=0
    override var y: Int=0
    override var width: Int=0
    override var height: Int=0

    init {
        var size=Painter.size("img/gameover.gif")
        width=size[0]
        height=size[1]

        x=GameConfig.WINDOW_WIDTH/2-width/2
        y=GameConfig.WINDOW_HEIGHT-height
    }

    override fun draw() {
//        println("x=$x  y=$y")
        Painter.drawImage("img/gameover.gif",x,y)
    }

    override fun move(direction: Direction) {
        if(y<=GameConfig.WINDOW_HEIGHT/2-height/2) return
        when(currentDirection){
            Direction.UP->y-=speed
            Direction.DOWN->y+=speed
            Direction.LEFT->x-=speed
            Direction.RIGHT->x+=speed
        }
    }
}